<?php

class Fax {
  
  public $id;
  public $pages;
  public $telf;
  public $par;
  public $ts;
  
  private $imagemagick_path;
  private $fax_url;
  
  function __construct($id) {
    $this->imagemagick_path = FaxConfig::getConfig()->getValue('imagemagick_path');
    $this->fax_url = FaxManager::getFaxUrl($id);
    
    $this->id = $id;
    $this->pages = exec($this->imagemagick_path.'identify -format "%n" '.$this->fax_url);
    $this->telf = exec($this->imagemagick_path.'identify -format "%c" '.$this->fax_url.'[0]');
    $this->par = $this->getPAR($id);
    $this->ts = exec($this->imagemagick_path.'identify -format "%[timestamp]" '.$this->fax_url.'[0]');
  }
  
  function getPAR($id){
    $res_x = explode(" ", exec($this->imagemagick_path.'identify -format "%x" '.$this->fax_url.'[0]') );
    $res_y = explode(" ", exec($this->imagemagick_path.'identify -format "%y" '.$this->fax_url.'[0]') );
    return $res_y[0]/$res_x[0];
  } 
  
}
?>